# -*- coding=utf-8 -*-
import locale

"""
expense_catelog_dic = {'Eating':'吃',
                       'Housing':'住',
                       'Traffic':'行',
                       'Entertain':'娱',
                       'Shopping':'购',
                       'Phone':'话',
                       'Book':'阅',
                       'Travel':'旅'}
"""
expense_catelog_dic = [{'name': 'Eating',       'transs':_('Eating')},
                       {'name': 'Housing',      'transs':_('Housing')},
                       {'name': 'Traffic',      'transs':_('Traffic')},
                       {'name': 'Entertain',    'transs':_('Entertain')},
                       {'name': 'Shopping',     'transs':_('Shopping')},
                       {'name': 'Phone',        'transs':_('Phone')},
                       {'name': 'Book',         'transs':_('Book')},
                       {'name': 'Travel',       'transs':_('Travel')},
                       {'name': 'Misc',        'transs':_('Misc')},
                       ]


"""
expense_through_dic = {'Cash':'现金',
'Credit Card':'信用卡',
'Saving Card':'储蓄卡'}
"""
expense_through_dic = [{'name':'Cash',  'trans':_('Cash')},
                       {'name':'Credit Card',   'trans':_('Credit Card')},
                       {'name':'Saving Card',   'trans':_('Saving Card')},
                       ]

incoming_dic = [{'name':'salary', 'trans':_('salary')},
                {'name':'bonus', 'trans':_('bonus')},
                {'name':'parents', 'trans':_('parents')},
                {'name':'other', 'trans':_('other')},
                ]


expense_to_whom_dic = [{'name':'I',       'trans':_('I')},
                       {'name':'My Love', 'trans':_('My Love')},
                       {'name':'Friends', 'trans':_('Friends')}]


from google.appengine.ext import webapp
from google.appengine.api import users
import cgi

class TransRequestHandler(webapp.RequestHandler):
    def checkAmount(self):
        try:
            amount = float(cgi.escape(self.request.get('amount')))
            # Elimit to x.xx to elimit to lenght of other page.
            amount_str = str("%.2f"%amount)
            self.amountnum = amount_str
        except ValueError, err:
            logging.error("user: %s input amount error, request:%s .."%(users.get_current_user(), self.request))
            self.response.out.write("<html><body><pre>%s:%s </pre></body></html>" % (_("Input Money Error"), err))
            self.response.set_status("404");
            return False
        return True
